<template>
  <div class="lg:flex">
    <!-- <Avatar :src="userinfo.avatar || headerImg" :size="72" class="!mx-auto !block" icon="person"/> -->
    <Avatar :size="72" class="!mx-auto !block" :icon="userinfo.nickname" />
    <div class="md:ml-6 flex flex-col justify-center md:mt-0 mt-2">
      <h1 class="md:text-lg text-md">欢迎, {{ userinfo.nickname }}！</h1>
      <span class="text-secondary"> {{ userDistrictinfo(userinfo) }} </span>
    </div>
    <div class="flex flex-1 justify-end md:mt-0 mt-4">
      <div class="flex flex-col justify-center text-right">
        <span class="text-secondary"> 用户名 </span>
        <span class="text-2xl"> {{ userinfo.uname }} </span>
      </div>

      <div class="flex flex-col justify-center text-right md:mx-16 mx-12">
        <span class="text-secondary"> 用户组 </span>
        <span class="text-2xl">{{ userinfo.userGroupName }}</span>
      </div>
      <div class="flex flex-col justify-center text-right md:mr-10 mr-4">
        <span class="text-secondary"> 角色 </span>
        <span class="text-2xl"> {{ userinfo.roleName }} </span>
      </div>
     
    </div>
  </div>
</template>
<script lang="ts" setup>
  import { computed } from 'vue';
  import { Avatar } from 'ant-design-vue';
  import { useUserStore } from '/@/store/modules/user';
  import headerImg from '/@/assets/images/44.png';

  const userStore = useUserStore();
  const userinfo = computed(() => userStore.getUserInfo);
  const userDistrictinfo = (userinfo) => {
    if (userinfo.districtJson) {
      const distJson = JSON.parse(userinfo.districtJson);
      const dists: string[] = [];
      distJson.forEach((element) => {
        dists.push(JSON.parse(element).regionName);
      });

      return dists.join('-');
    }

    return '-/-';
  };
</script>
